import request from '@/utils/request'
import { HTTP_METHOD } from '@/utils/http'

const BASE_URL = '/user'

/**
 * @export 获取/创建Basiq用户
 * @param {*} email
 * @param {*} mobile
 * @param {*} firstName
 * @param {*} lastName
 * @return {*}
 */
 export function getBasiqUser (data) {
  return request({
    url: `${BASE_URL}/create`,
    method: HTTP_METHOD.POST,
    baseURL: process.env.VUE_APP_RISK_ENGINE_BASE_API,
    data,
  })
}

/**
 * @export 获取机构列表
 * @return {*}
 */
export function getBasiqInstitutions () {
  return request({
    url: `${BASE_URL}/institutions`,
    method: HTTP_METHOD.GET,
    baseURL: process.env.VUE_APP_RISK_ENGINE_BASE_API,
  })
}

/**
 * @export 获取Basiq Token
 * @param {*} data
 * @return {*}
 */
 export function getBasiqToken (data) {
  return request({
    url: `${BASE_URL}/token`,
    method: HTTP_METHOD.POST,
    baseURL: process.env.VUE_APP_RISK_ENGINE_BASE_API,
  })
}

/**
 * @export 创建basiq授权连接
 * @param {*} loginId
 * @param {*} password
 * @param {*} institution 机构
 */
export function basiqConnections (data) {
  return request({
    url: `${BASE_URL}/connections`,
    method: HTTP_METHOD.POST,
    baseURL: process.env.VUE_APP_RISK_ENGINE_BASE_API,
    data,
  })
}

/**
 * @export 获取用户授权账户
 * @return {*}
 */
export function getBasiqAccounts () {
  return request({
    url: `${BASE_URL}/selectedaccounts`,
    method: HTTP_METHOD.GET,
    baseURL: process.env.VUE_APP_RISK_ENGINE_BASE_API,
  })
}
